<?php
// File Security Check
if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && basename( __FILE__ ) == basename( $_SERVER['SCRIPT_FILENAME'] ) ) :
	die ( 'You do not have sufficient permissions to access this page!' );
endif;

/* Template Name: Blog - Masonry */

add_filter( 'nice_load_flexslider_js', '__return_true', 10 );
add_filter( 'nice_load_more_posts_loader_js', '__return_true', 10 );

get_header(); ?>

<?php get_template_part( 'page-title' ); ?>

<?php

if ( get_query_var( 'paged' ) ) :
	$paged = get_query_var( 'paged' );
elseif ( get_query_var( 'page' ) ) :
	$paged = get_query_var( 'page' );
else :
	$paged = 1;
endif;

query_posts( array( 'post_type' => 'post', 'paged' => $paged ) ); ?>

<!-- BEGIN #container -->
<div id="container" class="clearfix">

<!-- BEGIN #content -->
<section id="content" class="full-width blog-masonry ">

<?php if ( have_posts() ) : ?>

	<ul class="three-col-grid grid clearfix">

	<?php

			$columns = 3;
			$loop = 0;

			while ( have_posts() ) : the_post();

			$loop++;
			?>
			<li id="post-<?php the_ID(); ?>" class="masonry-item <?php if ( $loop % $columns == 0) echo 'last'; if ( ( $loop - 1 ) % $columns == 0 ) echo 'first'; ?>">

				<!-- BEGIN .post -->
				<article class="post clearfix">

					 <?php if ( has_post_thumbnail() ) :	?>
							<figure class="featured-image view view-more">
									<a href="<?php the_permalink(); ?>" title="<?php printf( __( 'Permanent Link to %s', 'nicethemes' ), get_the_title() ); ?>">
										<?php nice_image( array( 'width' => 580, 'height' => 405, 'class' => 'wp-post-image' ) ); ?>
										<div class="mask"></div>
									</a>
							</figure>
					<?php endif; ?>

					<header>
						<h2>
							<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf( __( 'Permanent Link to %s', 'nicethemes' ), get_the_title() ); ?>"><?php the_title(); ?></a>
						</h2>
						<?php nice_post_meta_masonry(); ?>
					</header>

					<div class="entry">

						<div class="post-content">
							<?php nice_excerpt( 400 ); ?>
						</div>

					</div>

					<a class="readmore" href="<?php echo get_permalink( get_the_ID() ); ?>" title="<?php printf( __( 'Permanent Link to %s', 'nicethemes' ), get_the_title() ); ?>"> <?php _e( 'Read More', 'nicethemes' ); ?></a>

			<!-- END .post -->
			</article>

			</li>

	<?php endwhile; ?>

	</ul>

<?php else : ?>
    
        <?php _e( 'Sorry, no posts matched your criteria.', 'nicethemes' ); ?>
    
<?php endif; ?>

<div id="posts_ajax_loader"></div>

<!-- END #content -->
</section>

<!-- END #container -->
</div>

<?php get_footer(); ?>